﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using System.Collections.Generic;
using HotelManager.ServiceReference1;
using HotelManager.ViewModels;
using SilverlightStudentManager.ViewModels;

namespace HotelManager.ViewModel
{
    public class ChucVuViewModel : ViewModelBase
    {
        private ChucVuClient ChucVuclient = new ChucVuClient();
        private CHUCVU newChucVu = new CHUCVU();
        public ChucVuViewModel()
        {
            //MessageBox.Show("Called");
            this.GetbyAllChucVu();
        }
        private void GetbyAllChucVu()
        {
            //MessageBox.Show("Called");
            this.ChucVuclient.GetByAllChucVuCompleted += (s, e) =>
            {
                MessageBox.Show(e.Result[0].MaChucVu.ToString());
                this.ListChucVu = e.Result;

            };
            this.ChucVuclient.GetByAllChucVuAsync();
        }
        private IEnumerable<CHUCVU> listChucVu;
        public IEnumerable<CHUCVU> ListChucVu
        {
            get
            {
                return this.listChucVu;
            }

            set
            {
                this.listChucVu = value;
                this.OnPropertyChanged("ListChucVu");
            }
        }
        // current Bac luong
        private CHUCVU currentChucVu;
        public CHUCVU CurrentChucVu
        {
            get
            {
                return this.currentChucVu;
            }
            set
            {
                this.currentChucVu = value;
                this.newChucVu = this.CurrentChucVu;
                if (this.currentChucVu == null)
                {
                    this.newChucVu = new CHUCVU();
                }
                //else this.RefreshToViewErrors();
                this.OnPropertyChanged("CurrentChucVu");
            }
        }
        private void RefreshToViewErrors()
        {
            //this.MaChucVu = this.newChucVu.MaChucVu;
            //this.TenChucVu = this.newChucVu.HoTen;
        }
    }
}
